<template>
  <!-- <template>只能向外暴露一个跟标签，需要最外包裹一个div -->
  <div>
   <home-header :city="city"></home-header>
   <home-swiper :list="swiperList"></home-swiper>
   <home-icons :icon="iconList"></home-icons>
   <home-recommend :rec="RecommendList"></home-recommend>
   <home-weekend :weekend="WeekendList"></home-weekend>
    <!-- <router-link to="/List">列表页</router-link> -->
    <!-- <a href=""></a>与a标签相似 -->
  </div>

</template>
<script>
// 使用局部组件
import HomeHeader from './components/Header'
import HomeSwiper from './components/Swiper'
import HomeIcons from './components/Icons'
import HomeRecommend from './components/Recommend'
import HomeWeekend from './components/Weekend'
import axios from 'axios'
export default {
  name: 'Home',
  // 使用局部组件，需要声明
  components: {
    HomeHeader,
    HomeSwiper,
    HomeIcons,
    HomeRecommend,
    HomeWeekend
    // 页面使用需要改为小写连写<home-header></home-header>
  },
  data () {
    return {
      city: '北京',
      // swiperList此处为值，
      swiperList: [],
      iconList: [],
      RecommendList: [],
      WeekendList: []
    }
  },
  methods: {
    getHomeInfo () {
      axios.get('/api/index.json')
        .then(this.getHomeInfoSucc)
    },
    getHomeInfoSucc (res) {
      console.log(res)
      res = res.data
      if (res.ret && res.data) {
        const data = res.data
        // this.city = data.city
        this.swiperList = data.swiperList
        // console.log(data.swiperList)
        this.iconList = data.iconList
        this.RecommendList = data.recommendList
        this.WeekendList = data.weekendList
      }
    }
  },
  mounted () {
    this.getHomeInfo()
  }
}
</script>
<style>

</style>
